<?php
namespace User\Controller;
use User\Controller\BaseController;
class CouponController extends BaseController {
    private $perpage = 9;
    private $M;
    public function _initialize(){
        $this->M = M("coupon");
    }
    /*
    *   分页显示
    */
    public function index(){
        $count = $this->M->count();    // 总记录数
        if(empty($nowpage)){
            $nowpage = 1;
        }
        $Page = new \Think\Page($count, $this->perpage);
        $Page->setConfig("prev", "上一页");
        $Page->setConfig("next", "下一页");
        $list = $this->M->limit($Page->firstRow.','.$Page->listRows)->where("quantity>0 and day>".time())->select();   // 每页的数据数组
        $show = $Page->show();  // 页码链接内容
        $this->assign("list", $list);
        $this->assign("page", $show);
        echo R("Home/Navlink/index");
        $this->display();
    }
}